export function formValidate(content,type){
  let email = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
  let phone = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
  if(type == 'require'){
    let body = content
    if (body == null) {
      return true
    }
    if (typeof content === String) {
      body = body.trim()
    }
    if (!(body instanceof Object)) {
      // console.log(body)
      body = body.toString()
    }
    if (Object.keys(body).length === 0) {
      return true // 如果为空,true
    }
    return false // 如果不为空，则会执行到这一步，返回false
  }

  if(type == 'email'){
    return email.test(content)
  }

  if(type == 'phone'){
    return phone.test(content)
  }
}

export function removeSpace(content){
  return content.replaceAll(" ","")
}
